// JavaScript Document
function Closeanno(){
	var dxanno=G("dxanno");
	dxanno.style.display="none";
	}
function dtdisplay(){
	var dtatten=G("dtatten");
	dtatten.style.display="block";
	}
function dthidden(){
	var dtatten=G("dtatten");
	dtatten.style.display="none";
	}
	
//

function isUnsignedInteger(value,len)  {  
  	var reg1=/^\d{11}$/;
  	if(len=='6'){
  		reg1=/^\d{6}$/;
  	}
	return reg1.test(value);
}
function getCode(obj){
    var phonenum = G("myphone").value.trim();
	var randvalue = G('randvalue');
	if (randvalue != null) {
		randvalue = randvalue.value.trim();
		if(randvalue.value == ""){
		    G("correct").style.display = "none";
			G("error").innerHTML = "请输入验证码！";
			G("error").style.display = "inline";
			return;
		}
	} else {
		randvalue = "";
	}
	if(phonenum!=null && phonenum.length>0 && isUnsignedInteger(phonenum,"11") && phonenum.match(/^1[3584]/)){
		if(cannotSend()){
			G("correct").style.display = "none";
			G("error").innerHTML = "对不起，本机距上次获取体验码不足5分钟，请稍后再试！";
			G("error").style.display = "inline";
			return;
		}
		G("correct").style.display = "none";
		G("error").style.display = "none";
		G("wait").innerHTML = "<img  src=\"http://image3.qqvoice.com:8181/website/image/Loading.gif\">正在操作，请稍后...</img>";
		G("wait").style.display = "inline";
        var request = new AjaxRequest();
		request.open("post","http://www.qqvoice.com/getTryCallBackCode.do",true);
		request.setParameter("phone",phonenum);
		request.setParameter("randvalue", randvalue);
		request.onBack = function(){
		G("wait").style.display = "none";
			var data = request.getText();
			if(data!=null){
				switch(data){
					case '0':
						G("error").style.display = "none";
						if(obj == 1)
						G("correct").innerHTML = "体验码已发至<font color='#f46022'>"+phonenum+"</font>，可能会因为信号而延时，请稍等!</a>";
						else 
						G("correct").innerHTML = "体验码已发至<font color='#f46022'>"+phonenum+"</font>，可能会因为信号而延时，请稍等如未收到体验码，请点此<a href=\"javascript:reGetCode();\">重新获取体验码</a>";
						G("correct").style.display = "block";
						G("UserNameField").style.display = "none";
					    G('tycode').disabled="";
					    G('sendPhone').disabled="";
					    G('tycode').style.background='';
					    G('sendPhone').style.background='';
					    G("getfee").disabled="";
						G("getfee").className="tiyanbtn";	
						if (randvalue != ""){
						     G("U_CodeField").style.display="none";
						}	   
						break
					case '1':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，系统忙，请稍后再试！";
						G("error").style.display = "inline";
						break    
					case '2':
						
						if(G('sta2_step2')!= null){
						G("sta2_step1").style.display = "none";
						G("sta2_step2").style.display = "block";
						}
						else{
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，该号码已经体验或已经购买过手机拨打套餐！";
						G("error").style.display = "inline";
						}
						break
					case '3':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，用户未登录，请登录后再试！";
						G("error").style.display = "inline";
						break
					case '4':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，您的手机号码输入有误，请重新输入！";
						G("error").style.display = "inline";
						break
					case '5':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，该号码24小时内已经获取两次了，不可再次领取！";
						G("error").style.display = "inline";
						break
					case '6':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，请不要频繁获取体验码！";
						G("error").style.display = "inline";
						break
					case '7':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，您输入的被叫号码有误！";
						G("error").style.display = "inline";
						break
					case '8':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，您输入的体验错误！";
						G("error").style.display = "inline";
						break
					case '9':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，请不要频繁提交！";
						G("error").style.display = "inline";
						break
					case '10':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，您输入的验证码有误！";
						G("error").style.display = "inline";
						break
					case '11':
						G("correct").innerHTML = "";
						G("correct").style.display = "none";
						G("myphone").disabled = "disabled";
						G("huoqutiyan").style.display = "none";
					    G('U_RePasswordField').style.display = "none";
					    G('tycode').value = "111111";
					    G('sendPhone').disabled="";
					    G('sendPhone').style.background='';
					    G("getfee").disabled="";
						G("getfee").className="tiyanbtn";	
						if (randvalue != ""){
						     G("U_CodeField").style.display="none";
						}	   
						break
					case '15':
						G("correct").innerHTML = "";
						G("correct").style.display = "none";
						G("myphone").disabled = "disabled";
						G("huoqutiyan").style.display = "none";
					    G('U_RePasswordField').style.display = "none";
					    G('tycode').value = "111111";
					    G('sendPhone').disabled="";
					    G('sendPhone').style.background='';
					    G("getfee").disabled="";
						G("getfee").className="tiyanbtn";	
						if (randvalue != ""){
						     G("U_CodeField").style.display="none";
						}		   
						break
					default:
				}
			}
		}
		request.send();
  }else if(phonenum ==null || phonenum.length<1){
		G("correct").style.display = "none";
		G("error").innerHTML = "对不起，请输入您的手机号码！";
		G("error").style.display = "inline";
	}else {
		G("correct").style.display = "none";
		G("error").innerHTML = "对不起，您的手机号码输入有误，请重新输入！";
		G("error").style.display = "inline";
	}
}
//
function cannotSend(){
	var oldtime = getCookie("EXPSMSSENDTIME");
	var usernumber = getCookie("EXPUSERSENDPHONEMAIL");
	var nowNumber = getCookie("UNREGISTEREDEXPERIENCE");
	if(oldtime==null){
		oldtime = 0;
	}
	var newtime =  new Date().getTime();
	if((parseInt(newtime)-parseInt(oldtime)*1000)<5*60*1000 && usernumber == nowNumber){
		return true;
	}
	return false;
}

function reGetCode(){
    
	getCode(1);
	}
	
//
function getCall(){
    G("getfee").disabled="disabled";
	var code = G("tycode").value.trim();
	var sendPhone = G("sendPhone").value.trim();
	if(sendPhone == null || sendPhone.length<1){
	    G("correct").style.display = "none";
		G("error").innerHTML = "对不起，请您输入被叫号码！";
		G("error").style.display = "inline";
		G("getfee").disabled="";
		return ;
	}

	if(code!=null && code.length>0 && isUnsignedInteger(code,"6")){
		G("correct").style.display = "none";
		G("error").style.display = "none";
		G("wait").innerHTML = "<img  src=\"http://image3.qqvoice.com:8181/website/image/Loading.gif\">正在操作，请稍后...</img>";
		G("wait").style.display = "inline";
	
		var request = new AjaxRequest();
		request.open("post","http://www.qqvoice.com/saveTryCallBackCode.do",true);
		request.setParameter("code",code);
		request.setParameter("callee",sendPhone);
		request.onBack = function(){
			G("wait").style.display = "none";
			var data = request.getText();
			if(data!=null){
				switch(data){
					case '0':
					    if(G("sta1_step1") != null){
                        G("sta1_step1").style.display="none";
                        G("weidengruty").className="wystatus2_t";
                        G("weidengruty").innerHTML = "手机拨打套餐时长：<font color='#ff5500'>6</font>分钟";
                        setTimeout("showresult()",120000)
                        }
                        else 
                        G("sta2_step1").style.display="none";
                        
                        G("sta1_step2").style.display="block";
                        G("myphone1").value=G("myphone").value;
                        G("callee").innerHTML = sendPhone;
						break
					case '1':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，系统忙，请稍后再试！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break 
					case '2':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，该号码已经体验了！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break
					case '3':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，该手机号码已领取过免费体验话费，不可再次领取！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break   
					case '14':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起,您输入的被叫号码和绑定号码一致！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break
					case '7':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，您的输入的被叫号码错误！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break
					case '8':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，您提交体验码错误！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break
					case '9':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，您提交体验码过于频繁！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break
					default:
				}
			}
		}
		request.send();
	}else{
		G("correct").style.display = "none";
		G("error").innerHTML = "对不起，您的体验码输入有误，请重新输入！";
		G("error").style.display = "inline";
		G("getfee").disabled="";
	}
}
//
function callback(){
  G("getfee").disabled="disabled";
	var sendPhone = G("sendPhone").value.trim();
	if(sendPhone == null || sendPhone.length<1){
	    G("correct").style.display = "none";
		G("error").innerHTML = "对不起，请您输入被叫号码！";
		G("error").style.display = "inline";
		G("getfee").disabled="";
		return ;
	}else{
		G("correct").style.display = "none";
		G("error").style.display = "none";
		G("wait").innerHTML = "<img  src=\"http://image3.qqvoice.com:8181/website/image/Loading.gif\">正在操作，请稍后...</img>";
		G("wait").style.display = "inline";
		var request = new AjaxRequest();
		request.open("post","http://www.qqvoice.com/u/tyCallback.do",true);
		request.setParameter("callee",sendPhone);
		request.onBack = function(){
			G("wait").style.display = "none";
			var data = request.getText();
			if(data!=null){
				switch(data){
					case '0':
                        G("sta2_step4").style.display="none";
                        G("sta1_step2").style.display="block";
                        G("callee").innerHTML = sendPhone;
						break
					case '1':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，系统忙，请稍后再试！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break 
					case '3':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，请您先登入！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break 
					case '14':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起,您输入的被叫号码和绑定号码一致！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break
					case '7':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，您的输入的被叫号码错误！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break
					case '13':
						G("correct").style.display = "none";
						G("error").innerHTML = "对不起，您的套餐已过期！";
						G("error").style.display = "inline";
						G("getfee").disabled="";
						break
					default:
				}
			}
		}
		request.send();
	}
}

function firstBind(){
	var sendPhone = G("bangdingphone").value.trim();
	if(sendPhone == null || sendPhone.length != 11){
		G("band1").innerHTML = "请您输入正确的手机号码！";
		G("band1").style.display = "inline";
		return ;
	}else{
		var request = new AjaxRequest();
		request.open("post","http://www.qqvoice.com/u/firstBind.do",true);
		request.setParameter("phone",sendPhone);
		request.onBack = function(){
			var data = request.getText();
			if(data!=null){
				switch(data){
					case '0':
                        G("fastloin_div2").style.display="none";
                        G("fastloin_div3").style.display="block";
                        G("successband").innerHTML = sendPhone;
						break
					case '1':
						G("band1").innerHTML = "对不起，系统忙，请稍后再试！";
						G("band1").style.display = "inline";
						break 
					case '3':
						G("band1").innerHTML = "对不起，请您先登入！";
						G("band1").style.display = "inline";
						break 
					case '4':
						G("band1").innerHTML = "对不起,您输入的号码根式有误！";
						G("band1").style.display = "inline";
						break
					case '16':
						G("band1").innerHTML = "对不起,您的手机已经绑定！";
						G("band1").style.display = "inline";
						break
					default:
				}
			}
		}
		request.send();
	}
}
function show1(obj){

  if(obj == "1"){
  G("fastloin_div2").style.display="block";
  }else{
   window.location.href="http://account.qqvoice.com/login.do?to=http://www.qqvoice.com/phoneCall.do";
  }
}
function hideWinlogin(obj){

      if(obj == 1)
          G("fastloin_div1").style.display="none";
      else if(obj == 2)
          G("fastloin_div2").style.display="none";
      else if(obj == 3)
          G("fastloin_div3").style.display="none";
      else if(obj == 4)
          G("fastloin_div4").style.display="none";
      else if(obj == 5)
          G("fastloin_div5").style.display="none";
}

function tefuhao(obj){
        if(obj == 1){
        hideWinlogin(3);
        }
        if(cannotSend()){
            G("dxanno").style.display="none";
			G("terror").innerHTML = "对不起，本机距上次获取特服号不足5分钟，请稍后再试！";
			G("terror").style.display = "inline";
			return;
		}
	    var sendPhone = G("sendtefuhao").value.trim();
		var request = new AjaxRequest();
		request.open("post","http://www.qqvoice.com//u/sendCallBackNumber.do",true);
		request.setParameter("phone",sendPhone);
		request.onBack = function(){
			var data = request.getText();
			if(data!=null){
				switch(data){
					case '0':
                        G("dxanno").style.display="block";
                        G("band2").innerHTML = "短信特服号已发至<font>"+sendPhone+"</font>，可能会因为信号而延时，请稍等如未收到特服号，请点此<a href='javascript:tefuhao(0)'>重新获取体验码</a>，建议将短信特服号保存为手机联系人";
            
						break
					case '1':
					    G("dxanno").style.display="none";
						G("terror").innerHTML = "对不起，系统忙，请稍后再试！";
						G("terror").style.display = "inline";
						
						break 
					case '3':
					    G("dxanno").style.display="none";
						G("terror").innerHTML = "对不起，请您先登入！";
						G("terror").style.display = "inline";
						
						break 
					case '4':
					     G("dxanno").style.display="none";
						G("terror").innerHTML = "对不起,您输入的号码根式有误！";
						G("terror").style.display = "inline";
						
						break
					case '5':
					    G("dxanno").style.display="none";
						G("terror").innerHTML = "对不起,一个手机号24小时内只能发送两次！";
						G("terror").style.display = "inline";
						
						break
					case '12':
					   G("dxanno").style.display="none";
						G("terror").innerHTML = "对不起,您的手机号码未绑定！";
						G("terror").style.display = "inline";
						
						break
					case '6':
					   G("dxanno").style.display="none";
						G("terror").innerHTML = "对不起,请不要频繁获取！";
						G("terror").style.display = "inline";
						
						break
					default:
				}
		}
	}
		request.send();
}

function showPhonelist(){
	var s = "";
	var unumber =  getCookie("unumber");
	if(unumber!=null){
		var str = getCookie("phonelist_"+unumber);
		if(str!=null){
			var strArray = str.split("|");
			for(var i=0;i<strArray.length;i++){
				if(strArray[i].trim().length>0){
					s = s + "<a href=\"javascript:callhistory('"+strArray[i].trim()+"');\">"+strArray[i].trim()+"</a><br/>";
				}
			}
		}
	}
	if(s == ""){
		s = "暂无通话记录！"
	}
	G("telephone").innerHTML = s;
	G("box1").style.display = "block";
}

function hidePhonelist(){
	G("box1").style.display = "none";
}
function callhistory(phone){
	G("sendPhone").value=phone;
}

function showresult(){
G("sta1_step2").style.display="none";
G("sta1_step4").style.display="block";
}